<template>
	<view>
		<view class="uni-panel">
			<uni-list v-if="info != null">
				<uni-list-item title="姓名" :rightText="info.name" />
				<uni-list-item title="教工号" :rightText="info.code" />
				<uni-list-item title="手机号" :rightText="info.phone" />
				<uni-list-item title="邮箱地址" :rightText="info.email" />
				<uni-list-item title="身份证号" :rightText="info.idcard" />
				<uni-list-item title="性别" :rightText="getSex" />
				<uni-list-item title="所属部门" :rightText="info.deptName" />
				<uni-list-item title="教工类型" :rightText="getType" />
				<uni-list-item title="学历" :rightText="getEducation" />
				<uni-list-item title="学位" :rightText="getDegree" />
				<uni-list-item title="入校时间" :rightText="info.startDate" />
			</uni-list>
		</view>
	</view>
</template>
<script>
	import { getTeacherByUser } from '@/api/user.js'
	import { getDicts, selectDictLabel } from '@/api/sys.js'
	export default {
		name: "EditInfo",
		data() {
			return {
				userId : null,
				info: null,
				educationOption: [],
				degreeOption: [],
				typeOption: [],
				sexOption: []
			}
		},
		onLoad() {
			 if(!this.$store.state.token){
				uni.navigateTo({
					url: '/pages/login/login'
				});
			}
		const user = this.$store.getters.user;
		this.userId = user.userId;
			getTeacherByUser(this.userId).then(response => {
				this.info = response.data;
			});
			getDicts('base_education').then(response => {
				this.educationOption = response.data;
			});
			getDicts('base_degree').then(response => {
				this.degreeOption = response.data;
			});
			getDicts('teacher_type').then(response => {
				this.typeOption = response.data;
			});
			getDicts('sys_user_sex').then(response => {
				this.sexOption = response.data;
			});
		},
		computed:{
			getEducation() {
				return selectDictLabel(this.educationOption, this.info.education)
			},
			getDegree() {
				return selectDictLabel(this.degreeOption, this.info.degree)
			},
			getType() {
				return selectDictLabel(this.typeOption, this.info.type)
			},
			getSex() {
				return selectDictLabel(this.sexOption, this.info.sex)
			}
		}
	}
</script>

<style>
	.uni-form-item .title {
		padding: 20rpx 0;
	}
</style>
